#ifndef ALARMDASHBOARD_H
#define ALARMDASHBOARD_H

#include <QScrollArea>
#include <QPropertyAnimation>
#include "alarmitemwidget.h"
#include "common.h"

class QVBoxLayout;

#define AlarmDashboardIns AlarmDashboard::Instance()

class AlarmDashboard : public QScrollArea {
    Q_OBJECT
public:
    explicit AlarmDashboard(QWidget *parent = nullptr);

    static AlarmDashboard *Instance();

private slots:
    void on_addAlarm(const AlarmData &data);
    void clearMessage();

protected:
void wheelEvent(QWheelEvent *event) override;

private:
    void setupContainer();
    void performSmoothScroll();
    void setAutoScrollEnabled(bool enable);

private:
    QWidget *m_container;
    QVBoxLayout *m_layout;
    int m_maxVisibleItems = 3;  //item对象池数量会x2
    int m_item_cuurentIndex = 0; //item下标计数
    QList<AlarmItemWidget*> m_itemPool;

    QPropertyAnimation *m_scrollAnimation;
    bool m_autoScrollEnabled = true;  // 新增自动滚动控制标志
};
#endif // ALARMDASHBOARD_H
